"""Miscellaneous utility functions
"""
__author__ = "Massimo Bonvicini (massimo.bonvicini@gmail.com)"
__version__ = "$Revision: 0.1 $"
__date__ = "$Date: 2004/05/05 21:57:20 $"
__license__ = "Python"

def genID(string):
    '''
    Generate a unique ID based on time and a string.
    
    '''
    import hashlib
    import time
    from random import random
    digest = hashlib.md5()
    digest.update(str(float(time.time()) * random()))
    digest.update(string)
    return digest.hexdigest()

def str_impl(anInstance, displayAttributeList):
    classLine = "\n%s.%s(%i):\n" % (anInstance.__class__.__module__, anInstance.__class__.__name__, id(anInstance))
    return (classLine + "\n".join(["  %s: %s" % (key.rjust(8), anInstance.__dict__[key]) for key in displayAttributeList]))
